package com.luzhikun.jsptest.myjsp;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class PrintHtml extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //解决乱码
        response.setContentType("text/html;charset=UTF-8");
        //通过响应的输出流回传html页面数据
        PrintWriter writer = response.getWriter();
        writer.write(" <!DOCTYPE html>\r\n");
        writer.write(" <html lang=\"en\">\r\n");
        writer.write(" <head>\r\n");
        writer.write(" <meta charset=\"UTF-8\">\r\n");
        writer.write(" <title>Title</title>\r\n");
        writer.write(" </head>\r\n");
        writer.write(" <body>\r\n");
        writer.write(" 这是html页面数据\r\n");
        writer.write("  </body>\r\n");
        writer.write(" </html>\r\n");

    }

}